a2077c1d40ae4f3fbad786649a6271e5b6f103de,src/main/java/com/ociweb/pronghorn/network/HTTPClientRequestStage.java,HTTPClientRequestStage,hasOpenConnection,#Pipe#Pipe[]#ClientCoordinator#,460

Before Change


		int userId = Pipe.peekInt(requestPipe,   1); //user id always after the msg idx
		int port = Pipe.peekInt(requestPipe,     2); //port is always after the userId; 
			
		int hostMeta = Pipe.peekInt(requestPipe, 3); //host is always after port
 		int hostLen  = Pipe.peekInt(requestPipe, 4); //host is always after port

 		int hostPos  = Pipe.convertToPosition(hostMeta, requestPipe);		
 		byte[] hostBack = Pipe.byteBackingArray(hostMeta, requestPipe);
 		int hostMask = Pipe.blobMask(requestPipe);
 		
 		long connectionId;

 		if (Pipe.peekMsg(requestPipe, ClientHTTPRequestSchema.MSG_FASTHTTPGET_200)) {
 			connectionId = Pipe.peekLong(requestPipe, 5);//do not do lookup if it was already provided.
 		//	System.err.println("loaded connection "+connectionId);
 		} else {
     		connectionId = ccm.lookup(hostBack,hostPos,hostLen,hostMask, port, userId);
		//	System.err.println("first lookup connection "+connectionId);
 		}
		
 		
		activeConnection = ClientCoordinator.openConnection(ccm, hostBack, hostPos, hostLen, hostMask, port, userId, output, connectionId);
				
		
		if (null != activeConnection) {
			
			if (ccm.isTLS) {
				
				//If this connection needs to complete a hanshake first then do that and do not send the request content yet.
				HandshakeStatus handshakeStatus = activeConnection.getEngine().getHandshakeStatus();
				if (HandshakeStatus.FINISHED!=handshakeStatus && HandshakeStatus.NOT_HANDSHAKING!=handshakeStatus /* && HandshakeStatus.NEED_WRAP!=handshakeStatus*/) {
					
					
				//	System.err.println("no hanshake "+activeConnection.id+" status "+handshakeStatus);
					
					
					activeConnection = null;
					
					return false;
				}
				if ( HandshakeStatus.NEED_WRAP==handshakeStatus) {
					
					//TODO: send wrap request???
					
				}
				
				
			}
			
		} else {
			//this happens often when the profiler is running due to contention for sockets.
			
			//"Has no room" for the new connection so we request that the oldest connection is closed.
			
			//instead of doing this (which does not work) we will just wait by returning false.
//			ClientConnection connectionToKill = (ClientConnection)ccm.get( -connectionId, 0);
//			if (null!=connectionToKill) {
//				Pipe<NetPayloadSchema> pipe = output[connectionToKill.requestPipeLineIdx()];
//				if (PipeWriter.hasRoomForWrite(pipe)) {
//					//close the least used connection
//					cleanCloseConnection(connectionToKill, pipe);				
//				}
//			}
		
			//System.err.println("no connection");
			return false;
		}
		
		
		int outIdx = activeConnection.requestPipeLineIdx(); //this should be done AFTER any handshake logic
		if (!Pipe.hasRoomForWrite(output[outIdx])) {
			//System.err.println("no room for write to "+pipe);
			return false;
		}

After Change


 			
 			userId = Pipe.peekInt(requestPipe,   1); //user id always after the msg idx
 			port = Pipe.peekInt(requestPipe,     2); //port is always after the userId; 
 			hostMeta = Pipe.peekInt(requestPipe, 3); //host is always after port
 	 		hostLen  = Pipe.peekInt(requestPipe, 4); //host is always after port
 	 		hostPos  = Pipe.convertToPosition(hostMeta, requestPipe);		
 	 		hostBack = Pipe.byteBackingArray(hostMeta, requestPipe);
 	 		hostMask = Pipe.blobMask(requestPipe);
 			
     		connectionId = ccm.lookup(hostBack,hostPos,hostLen,hostMask, port, userId);
			//System.err.println("first lookup connection "+connectionId);
 		}
		
 		if (null!=activeConnection && activeConnection.getId()==connectionId) {
 			//logger.info("this is the same connection we just used so no need to look it up");
 		} else {
 			if (0==port) {
 	 			userId = Pipe.peekInt(requestPipe,   1); //user id always after the msg idx
 	 			port = Pipe.peekInt(requestPipe,     2); //port is always after the userId; 
 	 			hostMeta = Pipe.peekInt(requestPipe, 3); //host is always after port
 	 	 		hostLen  = Pipe.peekInt(requestPipe, 4); //host is always after port